<?php

    /**
     * User: Viet Anh
     * Date: 30/05/2014
     * Time: 16:41
     */

    require_once dirname(dirname(__FILE__)) . '/config/config.php';
    require_once DOCUMENT_ROOT . DIR_SHARED_DAO . 'dao_document_manage.php';

    class api_document_manage
    {
        public function __construct()
        {

        }

        public static function get_paid_document($user_id)
        {
            $dao_document_manage = new dao_document_manage();

            return $dao_document_manage->get_list_processed($user_id);
        }

        public static function get_unpaid_document($user_id)
        {
            $dao_document_manage = new dao_document_manage();

            return $dao_document_manage->get_list_processing($user_id);
        }

        public static function count_paid_document($user_id)
        {
            $paid_documents = self::get_paid_document($user_id);

            return sizeof($paid_documents);
        }

        public static function count_unpaid_document($user_id)
        {
            $unpaid_documents = self::get_unpaid_document($user_id);

            return sizeof($unpaid_documents);
        }

        public static function check_if_doc_paid($user_id, $doc_id)
        {
            $paid_documents = self::get_paid_document($user_id);
            foreach ($paid_documents as $document) {
                if ($document == $doc_id) {
                    return TRUE;
                }
            }

            return FALSE;
        }

        public static function check_if_doc_wait($user_id, $doc_id)
        {
            $unpaid_documents = self::get_unpaid_document($user_id);
            foreach ($unpaid_documents as $document) {
                if ($document == $doc_id) {
                    return TRUE;
                }
            }

            return FALSE;
        }
    }